/**
 * 
 */
package com.bagtrack.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;


/**
 * @author Brian Boyle
 * Nov 13, 2011
 *
 */
@Entity
@Table(name = "JOB")
public class Job {

    public static final String UNLOADING = "UNLOADING";
    public static final String ON_ROUTE = "ON_ROUTE";
    public static final String COMPLETE = "COMPLETE";

    private Long id;
    private String status;
    private Double longitude;
    private Double latitude;
    private Double speed;
    private Date jobDate;
    private Date startTime;
    private Date completionDate;
    private Double totalTime;
    private User user;
    private Route route;
    private Flight flight;

    /**
     * @param status
     * @param longitude
     * @param latitude
     * @param speed
     * @param jobDate
     * @param startTime
     * @param completionDate
     * @param totalTime
     */
    public Job(String status, Double longitude, Double latitude, Double speed, Date jobDate, Date startTime, Date completionDate, Double totalTime) {
        this.status = status;
        this.longitude = longitude;
        this.latitude = latitude;
        this.speed = speed;
        this.jobDate = jobDate;
        this.startTime = startTime;
        this.completionDate = completionDate;
        this.totalTime = totalTime;
    }

    public Job(String status, Double longitude, Double latitude, Double speed, Date jobDate, Date startTime) {
        this.status = status;
        this.longitude = longitude;
        this.latitude = latitude;
        this.speed = speed;
        this.jobDate = jobDate;
        this.startTime = startTime;
    }

    /**
     * Default Constructor
     */
    public Job() {

    }

    /**
     * @return the id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID")
    public Long getId() {
        return id;
    }


    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }


    /**
     * @return the status
     */
    @Column(name = "STATUS")
    public String getStatus() {
        return status;
    }


    /**
     * @param status the status to set
     */
    public void setStatus(String status) {
        this.status = status;
    }


    /**
     * @return the longitude
     */
    @Column(name = "LONGITUDE")
    public Double getLongitude() {
        return longitude;
    }


    /**
     * @param longitude the longitude to set
     */
    public void setLongitude(Double longitude) {
        this.longitude = longitude;
    }


    /**
     * @return the latitude
     */
    @Column(name = "LATITUDE")
    public Double getLatitude() {
        return latitude;
    }


    /**
     * @param latitude the latitude to set
     */
    public void setLatitude(Double latitude) {
        this.latitude = latitude;
    }


    /**
     * @return the speed
     */
    @Column(name = "SPEED")
    public Double getSpeed() {
        return speed;
    }


    /**
     * @param speed the speed to set
     */
    public void setSpeed(Double speed) {
        this.speed = speed;
    }


    /**
     * @return the jobDate
     */
    @Column(name = "JOB_DATE")
    public Date getJobDate() {
        return jobDate;
    }


    /**
     * @param jobDate the jobDate to set
     */
    public void setJobDate(Date jobDate) {
        this.jobDate = jobDate;
    }


    /**
     * @return the startTime
     */
    @Column(name = "START_TIME")
    public Date getStartTime() {
        return startTime;
    }


    /**
     * @param startTime the startTime to set
     */
    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }


    /**
     * @return the completionDate
     */
    @Column(name = "COMPLETION_DATE")
    public Date getCompletionDate() {
        return completionDate;
    }


    /**
     * @param completionDate the completionDate to set
     */
    public void setCompletionDate(Date completionDate) {
        this.completionDate = completionDate;
    }


    /**
     * @return the totalTime
     */
    @Column(name = "TOTAL_TIME")
    public Double getTotalTime() {
        return totalTime;
    }


    /**
     * @param totalTime the totalTime to set
     */
    public void setTotalTime(Double totalTime) {
        this.totalTime = totalTime;
    }


    /**
     * @return the user
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "USER_ID")
    public User getUser() {
        return user;
    }


    /**
     * @param user the user to set
     */
    public void setUser(User user) {
        this.user = user;
    }


    /**
     * @return the route
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "ROUTE_ID")
    public Route getRoute() {
        return route;
    }


    /**
     * @param route the route to set
     */
    public void setRoute(Route route) {
        this.route = route;
    }


    /**
     * @return the flight
     */
    @OneToOne
    @JoinColumn(name = "FLIGHT_ID")
    public Flight getFlight() {
        return flight;
    }


    /**
     * @param flight the flight to set
     */
    public void setFlight(Flight flight) {
        this.flight = flight;
    }

    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return "Job [id="
                + id
                + ", status="
                + status
                + ", longitude="
                + longitude
                + ", latitude="
                + latitude
                + ", speed="
                + speed
                + ", jobDate="
                + jobDate
                + ", startTime="
                + startTime
                + ", completionDate="
                + completionDate
                + ", totalTime="
                + totalTime
                + "]";
    }


}
